from typing import Optional
from datetime import datetime
from pydantic import BaseModel, Field, ConfigDict
from pydantic.types import UUID4
from app.schemas.archivable import Archivable


# 播报日志
# 共享属性
class BroadcastLogBase(BaseModel):
    broadcast_time: datetime = Field(..., description="播报对象名称")
    target_id: str = Field(..., description="播报对象ID")
    target_name: str = Field(..., description="播报对象名称")
    target_department: str = Field(..., description="所属部门")
    broadcast_task_name: str = Field(..., description="播报任务名称")
    trigger_type: str = Field(..., description="播报条件")


# 通过API创建时接收的属性
class BroadcastLogCreate(BroadcastLogBase):
    pass


# 通过API更新时接收的属性
class BroadcastLogUpdate(BroadcastLogBase):
    pass


# 数据库中存储的属性
class BroadcastLogInDBBase(BroadcastLogBase, Archivable):
    model_config = ConfigDict(from_attributes=True)

    id: UUID4


# 通过API返回的属性
class BroadcastLog(BroadcastLogInDBBase):
    pass


# 数据库中存储的属性（额外）
class BroadcastLogInDB(BroadcastLogInDBBase):
    broadcast_task_id: Optional[UUID4] = None
